<!DOCTYPE html>
<html>
  <head>
    <title>购物车</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
	<meta charset="utf-8">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="__PUBLIC__/addon/malltemplatehome/CSS/bootstrap.min.css">
    <link rel="stylesheet" href="__PUBLIC__/addon/malltemplatehome/CSS/reset.css">
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="__PUBLIC__/addon/malltemplatehome/js/jquery-1.11.3.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="__PUBLIC__/addon/malltemplatehome/js/bootstrap.js"></script>
	<!--购物车js代码-->
	<script src="js/simpleCart.js"></script>
	<!--自己的css样式-->
	<link rel="stylesheet" href="__PUBLIC__/addon/malltemplatehome/CSS/store.css">
	<script src="http://static.hongdayun.com/public/simplecartjs/3.0.5/simpleCart.min.js"></script>
	
	<script>
		simpleCart.currency({
			code: "RMB" ,
			name: "Chinese Yuan" ,
			symbol: "￥" ,
			delimiter: "" , 
			decimal: "." , 
			after: false ,
			accuracy: 2
		});
		simpleCart({
			cartColumns: [
				{ view:"image",attr: "img" , label: "" } ,
				{ attr: "name" , label: " " } ,
				{ attr: "price" , label: " ", view: 'currency' } ,
				{ view: "decrement" , label: false , text: "-" } ,
				{  view: "input" ,attr: "quantity" , label: " " } ,
				{ view: "increment" , label: false , text: "+" } ,
				{ attr: "total" , label: " ", view: 'currency' } ,
				//{ view: "remove" , text: "取消" , label: false }
			]
		});
		
			simpleCart({
		checkout: { 
			type: "SendForm" , 
			url: "__APP__/Home/Order/Create/Addon/Mall.html" ,

			method: "POST" , 

			} 
		});
		
		simpleCart.bind( 'beforeCheckout' , function( data ){

			
		   
			data.pay_type = $("input[name='pay_type']:checked").val(); //支付类型
			data.express_type = $("input[name='express_type']:checked").val(); //快递类型
			data.remark = $("#remark").val(); //留言
			data.name = $("#name").val(); //自提姓名
			data.tel = $("#tel").val(); //自提电话
			data.address_node = $("#address_node  option:selected").val();//自提节点
		data.order_type = 1;
		
			
			
			
		   
		});
		
		//自提不收邮费
		  	simpleCart.shipping(function(){
						if(simpleCart.total()>{$express_begin_money}){
							return 0
						}else{
							return {$express_money}
						}
					})
					
		   $(function(){
		  $(":radio").click(function(){
		  
		  
			var express_type = $("input[name='express_type']:checked").val();;
			
			
		   if(express_type=='1'){
								

								simpleCart.shipping(function(){
								  return 0;
								});
								
								$("input[type=radio][name=pay_type][value=1]").attr("checked",'checked')
								
								$("input[type=radio][name=pay_type][value=4]").attr("disabled",'disabled')
								
								simpleCart.load();
				}else if(express_type=='0'){
					
					$("input[type=radio][name=pay_type][value=1]").attr("checked",'checked')
							$("input[type=radio][name=pay_type][value=4]").removeAttr("disabled",'disabled')
									
				
					simpleCart.shipping(function(){
						if(simpleCart.total()>{$express_begin_money}){
							return 0
						}else{
							return {$express_money}
						}
					})
					simpleCart.load();
				}
		   
		   
		  });
		 });
	</script>
	
  </head>
  <body>
	<!--nav部分开始-->
	<header id="header">
		<div class="row shopping">
			<div class="col-xs-2 col-sm-2">
				<a href="__APP__/Home/Mall/Index/Addon/MallTemplateHome.html"><img src="__PUBLIC__/addon/malltemplatehome/images/icon58.jpg" width="100%"></a>
			</div>
			<div class="col-xs-8 col-sm-8">
				确认订单
			</div>
			<div class="col-xs-2 col-sm-2">
			</div>
		</div>
	</header>
	<!--content-->
	<div id="caigou">
		<div class="content">
			<p>产品清单</p>
			<div class="dingdan hide">暂无订单，快去<a href="__APP__/Home/Mall/Index/Addon/MallTemplateHome.html">首页</a>选购</div>
			<div class="simpleCart_items">购物车</div><!--显示购物车-->
			<div class="row caigou-contentm">
				<div class="row">
					<textarea class="form-control" rows="3" name="remark" id="remark" placeholder="订单备注"></textarea>
				</div>
			</div>
			
			<p>配送方式</p>
			<div class="row pay peisong">
				<div class="col-xs-6 col-sm-6">
				<label class="radio-inline">
					<input type="radio" id="express_type" name="express_type" checked  value="0"><span>送货上门</span>
					</label>
				</div>
				<div class="col-xs-6 col-sm-6">
				<label class="radio-inline">
					<input type="radio" id="express_type" name="express_type" value="1"><span>自提点自提</span>
					</label>
				</div>
			</div>
	
	<div class='dizhi'>		
		<div>	
			<p>收货地址</p>
			<a HREF="__APP__/Home/OAuth/Address/Addon/WeiXin.html">
			<div class="row address">
				<span>{$address.name}{$address.tel} - {$address.address}</span>
				<span class="pull-right">></span>
			</div>
			</a>
		</div>
		<div class='hide'>	
			<p>自提联系人</p>
			<div class="row pay">
				  <div class="col-xs-4 col-sm-4" style="padding-top:5px;">
					<label for="">选择自提点</label>
					</div>
					<div class="col-xs-8 col-sm-8">
					<select class='form-control' name="address_node" id="address_node">
						<volist name="address_node" id="address_node">
						<option value="{$address_node.id}">{$address_node.name}</option>
						</volist>
					</select>
				  </div>
			</div>
			<div class="row pay">
				<div class="col-xs-4 col-sm-4" style="padding-top:5px;">
					<label for="">收货人</label>
					</div>
					<div class="col-xs-8 col-sm-8">
					<input type="text" class="form-control" name="name" id="name" placeholder="请输入收货人姓名" value="{$address.name}">
				  </div>
			</div>
			<div class="row pay">
				  <div class="col-xs-4 col-sm-4" style="padding-top:5px;">
					<label for="">联系电话</label>
					</div>
					<div class="col-xs-8 col-sm-8">
					<input type="text" class="form-control"  name="tel" id="tel" placeholder="请输入收货人联系电话" value="{$address.tel}">
				  </div>
			</div>
			
		</div>
	</div>
			
			
			
			<p>支付方式</p>
			<div class="row pay payment">
				<div class="col-xs-4 col-sm-4">
				<label class="radio-inline">
					<input type="radio"  checked='checked' id="pay_type" name="pay_type"  value=" 1"><span>微信付款</span>
					</label>
				</div>
				<div class="col-xs-4 col-sm-4">
				<label class="radio-inline">
					<input type="radio" id="pay_type" name="pay_type" value="2"><span>余额支付</span>
					</label>
				</div>
				<div class="col-xs-4 col-sm-4">
				<label class="radio-inline">
					<input type="radio" id="pay_type"  name="pay_type" value="4"><span>货到付款</span>
					</label>
				</div>
				
				
			</div>
			
			
		
		</div>
	</div>
	
	<!--jiage-->
	<div id="jisuan">
		
		<div class="row total">
			<div class="col-xs-6 col-sm-6">
				<span>商品金额:</span>
			</div>
			<div class="col-xs-6 col-sm-6">
				<span class="pull-right simpleCart_total"></span>
			</div>
		</div>
		<div class="row total">
			<div class="col-xs-6 col-sm-6">
				<span>运费：</span>
			</div>
			<div class="col-xs-6 col-sm-6">
				<span class="pull-right simpleCart_shipping"></span>
			</div>
		</div>
		
		<div class="row jisuan-total">
			<div class="col-xs-6 col-sm-6">
				<span>需支付总金额</span>
			</div>
			<div class="col-xs-6 col-sm-6">
				<span class="pull-right simpleCart_grandTotal"></span>
			</div>
		</div>
	</div>
	<!--footer-->
	<footer class="footer">
		<div class="row">
			<p><a href='javascript:;' class="simpleCart_checkout">提交订单</a></p>
		</div>
	</footer>
	</div>

	<script>
		$(function(){
			$('.peisong input[type="radio"]').click(function(){
					var num=$(this).parent().parent().index();
					$('.dizhi>div').eq(num).removeClass('hide').siblings().addClass('hide');
			})
			
			/*自提点自提与货到付款不可同时选择*/
			
			$('.payment .radio-inline input[type="radio"]').change(function(){
		        var val=$('.payment .radio-inline input[type="radio"]:checked').val()
		        if(val==4){
		            $('.peisong .radio-inline input[type="radio"]').eq(1).attr('disabled',true)
		        }else{
		            $('.peisong .radio-inline input[type="radio"]').eq(1).attr('disabled',false)
		        }			        
			})
		
		})
	</script>
	
	
  </body>
</html>